<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head><title>
    我的书架 - 爱读书
</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="renderer" content="webkit"/>
    <script lang="javascript" type="text/javascript" th:src="@{//libs.baidu.com/jquery/1.11.3/jquery.min.js}"></script>
    <script lang="javascript" type="text/javascript" th:src="@{https://a.dushu.com/js/detectmobilebrowser.js}"></script>
    <link rel="stylesheet" th:href="@{../../static/css/core.min-20160809.css}">
    <link rel="stylesheet" th:href="@{../../static/css/dushu.min-20160802.css}">
    <link rel="stylesheet" th:href="@{../../static/css/font_1468833227_139596.css}">
    <!--导入分页样式-->
    <link rel="stylesheet" th:href="@{../../static/pagination/css/pagination.css}">
    <script th:src="@{../../static/pagination/js/pagination.js}"></script>

    <script th:inline="javascript">
        let counts = [[${counts}]];
    </script>
    <script th:inline="javascript">
        let name = [[${name}]];
    </script>
    <script>
        /*判断是否要显示登陆注册*/
        $(function () {
            if ($('.float-right').find("a:eq(0)").text() == '欢迎回来') {
                $(".float-right").find("a:eq(0)").attr("href", "javascript:;");
                $(".float-right").find("a:eq(1)").attr("href", "javascript:;");
            }
        });
        function deleteOrders(id,userId) {
            console.log(id);
            console.log(userId);
            if(confirm('你确定要删除？')){
                $.post(
                    "/like/delete",
                    {'id':id,'userId':userId},
                    function (data) {
                        console.log(data);
                        let str = "";
                        $.each(data,function (index,book) {
                            str+= "<li class=\"top\">\n" +
                                "                        <div class=\"book-info\">\n" +
                                "                            <div class=\"img152 float-left margin-right\"><a href=\"/index/toBookInfo/"+book.id+"\" target=\"_blank\"><img th:alt=\""+book.title+"\" src=\"/index/toHtml?Url="+book.image+"\"></a></div>\n" +
                                "                            <h3><a href=\"/index/toBookInfo/"+book.id+"\" title=\""+book.title+"\" target=\"_blank\" >"+book.title+"</a></h3>\n" +
                                "                            <p >"+book.author+"/"+datetimeFormat(book.date)+"</p>\n" +
                                "                             <span onclick=\"deleteOrders("+book.id+","+book.user_id+"})\" class=\"delete-span\" ><img src=\"/static/picture/delete.png\" alt=\"删除\"  title=\"删除\" style=\"width: 25px;height: 25px;\"></span>\n" +
                                "                        </div>\n" +
                                "                    </li>"
                        });
                        $(".searchlist").find("ul:eq(0)").empty();
                        $(".searchlist ").find("ul:eq(0)").append(str);
                    }
                )
            }
            return false;
        }
    </script>

</head>
<body>
<!--实现登录注册-->
<div class="layout bg border-bottom">
    <div class="container height-big text-gray">
        <span class="float-right">
            <a th:href="@{/index/toLogin}" th:text="${session.user}==null?'注册':'欢迎回来'" class="text-gray"></a>
            <span class="text-little">|</span>
            <a th:href="@{/index/toLogin}" class="text-gray" th:text="${session.user}==null?'登陆':${session.user.phone}"></a>
        </span>读书好，好读书，读好书！
    </div>
</div>


<!--可下拉式导航栏-->
<div class="layout bg border-bottom fixed-top hidden" style="z-index: 99;" id="fixednav">
    <div class="container"><div class="row">
        <div class="span4">
            <a href="javascript:;" title="读书网">
                <img th:src="@{/static/picture/login1.png}" alt="爱读书"></a></div>
        <div class="span13">
            <ul class="nav nav-inline nav-menu padding-top">
                <li><a href="/index/toRead" >每日一读</a></li>
                <li><a th:href="@{/index/toNovel/1}" >小说作品</a></li>
                <li><a th:href="@{/index/toNovel/2}" >经济管理</a></li>
                <li><a th:href="@{/index/toNovel/3}">历史传记</a></li>
                <li><a th:href="@{/index/toNovel/4}">生活时尚</a></li>
                <li><a th:href="@{/index/toNovel/5}" >文学艺术</a></li>
                <li><a th:href="@{/index/toNovel/6}" >社会科学</a></li>
                <li><a th:href="@{/index/toNovel/7}" >成功励志</a></li>
            </ul>
        </div>

        <!--轮播图的搜索框-->
        <div class="span7 text-right">
            <form name="searchform" th:action="@{/index/toSearch}">
                <div class="input-group padding-small-top">
                    <input type="text" class="wd input border-main" name="name" required="required" value="" autocomplete="off" size="30" placeholder="搜索海量图书/电子书/网络小说">
                    <span class="addbtn"><button class="button bg-main"><span class="icon-search"></span></button></span>
                </div>
            </form>
        </div>
    </div>
    </div>
</div>


<!--首页  top-->
<div class="container">
    <div class="row">
        <div class="span8"><a href="javascript:;"  title="爱读书"><img th:src="@{/static/picture/login2.png}"
                                                                    alt="爱读书"></a></div>

        <!--搜索框，通过form表单实现 -->
        <div class="span10 padding-big-top">
            <form name="searchform" th:action="@{/index/toSearch}" >
                <div class="input-group padding-little-top margin-big-right">
                    <input type="text" name="name" class="wd input input-big border-main" required="required" value="" size="30"
                           placeholder="搜索海量图书">
                    <span class="addbtn"><button class="button button-big bg-main" id="search_button"><span
                            class="icon-search text-large"></span></button></span>
                </div>
            </form>
        </div>

        <!--实现我的账户和书架-->
        <div class="span6 padding-large-top text-right">
            <div class="button-group" th:if="${session.user} !=null">
                <button type="button" class="button text-main"><span class="icon-user"></span> <a th:href="@{/index/toAccount/}+${session.user.phone}">我的账户</a></button>
                <button type="button" class="button text-main"><span class="icon-shujia"></span><a th:href="@{/index/toBookshelf/}+${session.user.id}">我的书架</a> </button>
            </div>
            <div class="button-group" th:if="${session.user} ==null">
                <button type="button" class="button text-main"><span class="icon-user"></span> <a href="javascript:;">我的账户</a></button>
                <button type="button" class="button text-main"><span class="icon-shujia"></span><a href="javascript:;">我的书架</a> </button>
            </div>
        </div>

    </div>
</div>


<!--位置-->
<div class="container margin-top">
    <div class="crumbs">
        当前位置： <a th:href="@{/}">首页</a><span class="icon-crumb"></span>
        <a href="javascript:;">我的书架</a><span class="icon-crumb"></span>
    </div>
</div>

<!--正文-->
<div class="container margin-top">
    <div class="bookdetails-left">
        <h4>你的书架中总共有<strong class="text-dot"th:text="${counts}">10</strong>本正在阅读的书</h4>

        <div class="searchlist">
            <ul>
                <!--图书展示-->
                <li class="top" th:each="book:${books}">
                    <div class="book-info">
                        <div class="img152 float-left margin-right"><a th:href="@{/index/toBookInfo/}+${book.book_id}" target="_blank"><img th:alt="${book.title}" th:src="'/index/toHtml?Url='+${book.image}"></a></div>
                        <h3><a th:href="@{/index/toBookInfo/}+${book.book_id}" th:title="${book.title}" target="_blank" th:text="${book.title}"></a></h3>
                        <p th:text="${book.author}+'/'+${#dates.format(book.date,'yyyy-MM-dd')}"></p>
                        <p style="line-height: 36px;"><a th:href="@{/book/getChapter/}+${book.book_id}+'/'+${book.chapter_id}" th:text="'已读到章节：'+${book.chapter_title}"></a></p>
                        <span  th:onclick="|deleteOrders(${book.id},${book.user_id})|" class="delete-span" ><img th:src="@{/static/picture/delete.png}" alt="删除"  title="删除" style="width: 25px;height: 25px;"></span>
                    </div>
                </li>
            </ul>
        </div>

    </div>
    <div class="bookdetails-right">

        <div class="tit"><h3>读书推荐</h3></div>
        <div id="J_commend" class="books-left border">
            <ul>
                <!--读书排行榜-->
                <li th:each="book,iterStat:${rankBooks}">
                    <p style="display: none;" class="fold">
                        <a th:href="@{/index/toBookInfo/}+${book.id}" th:title="${book.title}" target="_blank" th:text="${book.title}"><i th:text="${iterStat.count}"></i></a></p>
                    <div class="unfold" style="display: block;">
                        <i th:text="${iterStat.count}"></i>
                        <div>
                            <div class="img80"><a th:href="@{/index/toBookInfo/}+${book.id}" th:title="${book.title}" target="_blank"><img th:alt="${book.title}" th:src="'/index/toHtml?Url='+${book.image}"></a></div>
                            <h3><a th:href="@{/index/toBookInfo/}+${book.id}" th:title="${book.title}" target="_blank" th:text="${book.title}"></a></h3>
                            <p></p>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>
<div class="margin-large padding-large-top page text-center">
<!--分页-->
    <div id="pages" style="margin-top: -70px; margin-left: -25%;">
    </div>
</div>

<div class="layout" id="footer">
    <div class="container padding">
        <div class="text-center">
            <ul class="nav nav-inline">
                <li><a href="1587.html">关于读书</a> </li>
                <li><a href="1588.html">免责声明</a> </li>
                <li><a href="1589.html">读书目录</a> </li>
                <li><a href="1590.html">联系我们</a> </li>
            </ul>
        </div>
        <div class="text-center height-big">Copyright © 读书网 www.dushu.com 2005-2020, All Rights Reserved.</div>
        <div class="text-center height-big"><a href="javascript:;">鄂ICP备15019699号</a> <img th:src="@{/static/picture/beian.png}" style="vertical-align:middle;margin-left:10px;"> 鄂公网安备 42010302001612号</div>
    </div>
</div>
<script>
    $(function () {
        console.log(counts);
        new Pagination({
            element: '#pages',
            type: 1,
            pageIndex: 1,
            pageSize: 8,
            pageCount: 5,
            total: counts,
            jumper: true,
            singlePageHide: false,
            prevText: '上一页',
            nextText: '下一页',
            disabled: true,
            currentChange: function(index) {
                console.log(index);
                bookList(index);
            }
        });
    });

    function bookList(index) {
        console.log("模糊查询name"+name);
        $.post(
            "/index/doSearch",
            {'page':index,'name':name},
            function (data) {
                console.log("data:"+data);
                let str = "";
                $.each(data,function (index,book) {
                    let content = book.book_introduction.substring(0,100)+"....";
                    str+= "<li class=\"top\">\n" +
                        "                        <div class=\"book-info\">\n" +
                        "                            <div class=\"img152 float-left margin-right\"><a href=\"/index/toBookInfo/"+book.id+"\" target=\"_blank\"><img th:alt=\""+book.title+"\" src=\"/index/toHtml?Url="+book.image+"\"></a></div>\n" +
                        "                            <h3><a href=\"/index/toBookInfo/"+book.id+"\" title=\""+book.title+"\" target=\"_blank\" >"+book.title+"</a></h3>\n" +
                        "                            <p >"+book.author+"/"+datetimeFormat(book.date)+"</p>\n" +
                        "                            <p class=\"disc eps\" >"+content+"</p>\n" +
                        "                        </div>\n" +
                        "                    </li>"
                });
                $(".searchlist").find("ul:eq(0)").empty();
                $(".searchlist ").find("ul:eq(0)").append(str);
            }
        )
    }

    function datetimeFormat(longTypeDate) {
        var datetimeType = "";
        var date = new Date();
        date.setTime(longTypeDate - 28800000);
        //yyyy-MM-dd 00:00 格式日期
        datetimeType = date.getFullYear() + "-" + getMonth(date) + "-" + getDay(date) ;
        return datetimeType;
    }

    //返回 01-12 的月份值
    function getMonth(date) {
        var month = "";
        month = date.getMonth() + 1; //getMonth()得到的月份是0-11
        if (month < 10) {
            month = "0" + month;
        }
        return month;
    }

    //返回01-30的日期
    function getDay(date) {
        var day = "";
        day = date.getDate();
        if (day < 10) {
            day = "0" + day;
        }
        return day;
    }

    //返回小时
    function getHours(date) {
        var hours = "";
        hours = date.getHours();
        if (hours < 10) {
            hours = "0" + hours;
        }
        return hours;

    }

    //返回分
    function getMinutes(date) {
        var minute = "";
        minute = date.getMinutes();
        if (minute < 10) {
            minute = "0" + minute;
        }
        return minute;
    }
</script>
<script>
    $(function () {
        $("._jumper").css("display","none");
        $("._pages").css("display","block");
        $("._pages").css("margin-left","10%");
    });

</script>

<script lang="javascript" type="text/javascript" th:src="@{../../static/js/common.min-201706.js}"></script>
</body>
</html>
